<?php


namespace app\voip\func;


use app\voip\model\EDataType;
use app\voip\model\EUserSig;
use app\voip\model\QSeats;
use app\voip\model\QSeatsBind;

class QmFunc
{
    /**
     * @param $id
     * @return array|false|\PDOStatement|string|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    static public function checkSeats($id)
    {
        $obj = new QSeatsBind();
        return $obj->alias('s1')->join('q_seats s2','s1.sid=s2.id')->where('s1.uid',$id)->field('s2.*')->find();
    }

    /**
     * @param $where
     * @param $rows
     * @param $param
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    static public function getSigList($where, $rows, $param)
    {
        $obj = new EUserSig();
        return $obj->where($where)->order('id desc')->paginate($rows,false,['query'=>$param]);
    }

    /**
     * @param $data
     * @return EUserSig
     */
    static public function userSigAdd($data)
    {
        return EUserSig::create($data);
    }

    /**
     * @param $id
     * @return bool
     */
    static public function delUserSig($id)
    {
        return EUserSig::destroy($id);
    }
    /**
     * @param $id
     * @return bool
     */
    static public function delSeats($id)
    {
        return QSeats::destroy($id);
    }

    /**
     * @param $where
     * @param $rows
     * @param $param
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    static public function getExcelTypeList($where, $rows, $param)
    {
        $obj = new EDataType();
        return $obj->where($where)->paginate($rows,false,['query'=>$param]);
    }

    /**
     * @param $data
     * @return EDataType
     */
    static public function excelTypeAdd($data)
    {
        return EDataType::create($data);
    }

    /**
     * @param $id
     * @return bool
     */
    static public function delExcelType($id)
    {
        return EDataType::destroy($id);
    }
}